class R:
    def __init__(self, code, data, msg):
        self._code = code
        self._data = data
        self._msg = msg

    @property
    def code(self):
        return self._code

    @code.setter
    def code(self, value):
        self._code = value

    @property
    def data(self):
        return self._data

    @data.setter
    def data(self, value):
        self._data = value

    @property
    def msg(self):
        return self._msg

    @msg.setter
    def msg(self, value):
        self._msg = value

    def to_json(self):
        return {
            "code": self._code,
            "data": self._data,
            "msg": self._msg
        }
    @classmethod 
    def create(cls,code,data=None,msg=""):
        return cls(code,data,msg).to_json()
    @classmethod
    def success(cls, data=None, msg="Success"):
        return cls(200, data, msg).to_json()

    @classmethod
    def created(cls, data=None, msg="Created"):
        return cls(201, data, msg).to_json()

    @classmethod
    def bad_request(cls, msg="Bad Request"):
        return cls(400, None, msg).to_json()

    @classmethod
    def unauthorized(cls, msg="Unauthorized"):
        return cls(401, None, msg).to_json()

    @classmethod
    def reject(cls, msg="Reject"):
        return cls(403, None, msg).to_json()
    
    @classmethod
    def not_found(cls, msg="Not Found"):
        return cls(404, None, msg).to_json()

    @classmethod
    def server_error(cls, msg="Internal Server Error"):
        return cls(500, None, msg).to_json()